home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Tools - Objects
/
Virtual User 1.0
/
Example Scripts
/
MessagePassing Example
/
MessagePassingDemoLib.vu
< prev
next >
Wrap
Text File
|
1991-01-25
|
3KB
|
85 lines
#
# File: MessagePassingDemoLib.vu
#
# Contains: This is a demo library which is used by scripts Actor1.vu and
# Actor2.vu that run in parallel. They together demonstrate message
# passing while sharing tasks in this library. To run this demo you need two
# target machines (both having the Desk Accessory, Key Caps).
# It would be better if the two targets had different memory
# configurations and are running different versions of system software.
# Your command line should be as follows: (assuming the two
# targets have user names as Target1 and Target2 and that
# Actor1.vu, Actor2.vu and the library MessagePassingDemoLib.vu
# are all in your current working directory)
# VU -t1 '*:Target1' -s1 Actor1.vu -l1 Actor1.log ∂
# -t2 '*:Target2' -s2 Actor2.vu -l2 Actor2.log
#
# Caution: Do not forget to turn the key repeat off in the control panel on both
# the targets. The script takes a few seconds before you start seeing
# anything on the target screens.
#
# Written by: P Nagarajan
#
# Copyright: © 1990 by Apple Computer, Inc., all rights reserved.
#
# Change History:
#
# 8/16/90 naga creation
#
# To Do:
#
#### open a session with specified actor
task open_session(recipient)
begin
status := '';
while not (status = 'open')
begin
status := openSession(recipient);
end;
end; #open_session
#task to show a message passing demo using key caps on the target machine
task run_demo(fellow_actor)
begin
if match[menuItem t:'Key Caps' m:1]
begin
select [menuItem t:'Key Caps' m:1];
wait(3);#for Key Caps to come up
type k:{"You are going to see the messages received from the ",
"other actor (as is) in this window"};
wait(2);#to let the viewer read the typed sentence on target screen
type k:{returnKey};
my_name := actorName();
my_target := match[target];
my_target_name := my_target.t;
my_target_memory := (match[target]).r;
my_target_system := (match[system]).v;
dialogue := { {"Hey I am : ", my_name,"Stop" },
{"My purpose is to demonstrate message passing", "Stop"},
{"The target under my control is ", my_target_name, "Stop"},
{"My target has ", my_target_memory, " bytes of RAM", "Stop"},
{"My target is running system ", my_target_system, "Stop"},
{"Bye", "Stop"} };
for each sentence in dialogue
begin
send(fellow_actor, sentence);
reply := receive(fellow_actor);
type k:{fellow_actor.t,": "};
while (reply <> 'Stop')
begin
wait(1);
#wait is used here to avoid tight loops,
#and let other actors share time
if reply type k:{reply};
reply := receive(fellow_actor);
end;#while
wait(3);#to let the viewer read the typed sentence on target screen
type k:{returnKey};
end;#for each
close [window t:'Key Caps'];
end;#if key caps available
else println "sorry, cannot perform demo without Key Caps on my target";
end;#run_demo